package cn.itsource.system.service.impl;

import cn.itsource.system.domain.Role;
import cn.itsource.system.mapper.RoleMapper;
import cn.itsource.system.query.RoleQuery;
import cn.itsource.system.service.RoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    
    @Autowired
    private RoleMapper roleMapper;


    @Override
    public void insert(Role r) {
        roleMapper.insert(r);
    }

    @Override
    public void updateByPrimaryKeySelective(Role r) {
        roleMapper.updateByPrimaryKeySelective(r);
    }



    @Override
    public PageInfo<Role> pageInfo(RoleQuery roleQuery) {
        PageHelper.startPage(roleQuery.getCurrentPage(),roleQuery.getPageSize());
        List<Role> permissions = roleMapper.selectAll(roleQuery);
        return new PageInfo<Role>(permissions);
    }


    @Override
    public void deleteAll(List<Role> r) {
        roleMapper.deleteAll(r);
    }

    @Override
    public void deleteByPrimaryKey(Long id) {
        roleMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void savaRoleMenus(Role r) {
        roleMapper.savaRoleMenus(r);
    }

    @Override
    public void savaPermissions(Role r) {
        roleMapper.savaPermissions(r);
    }

    @Override
    public void deleteRoleMenus(Long rid) {
        roleMapper.deleteRoleMenus(rid);
    }

    @Override
    public void deleteRolePermissions(Long pid) {
        roleMapper.deleteRolePermissions(pid);
    }

}
